//排行榜指标
var array200=new Array();
var array300=new Array();
var array400=new Array();
var array500=new Array();
var array600=new Array();
var array700=new Array();

function initPaihIndexArr(){
	array200=new Array();
	array300=new Array();
	array400=new Array();
	array500=new Array();
	array600=new Array();
	array700=new Array();
}


//指标单位
var arraydanwei=new Array();
arraydanwei[0]= "人次";
arraydanwei[1]= "人/m2";
arraydanwei[2]= "元/人";
arraydanwei[3]= "元";
arraydanwei[4]= "%";
arraydanwei[5]= "元/人次";
arraydanwei[6]= "元/m2";
arraydanwei[7]= "人";
arraydanwei[8]= "min";
arraydanwei[9]= "人";
arraydanwei[10]= "人";
arraydanwei[11]= "%";
arraydanwei[12]= "%";
arraydanwei[13]= "%";
arraydanwei[14]= "%";
arraydanwei[15]= "人";
arraydanwei[16]= "%";
arraydanwei[17]= "人";
arraydanwei[18]= "%";
arraydanwei[19]= "人";
arraydanwei[20]= "%";
arraydanwei[21]= "min";
arraydanwei[22]= "人次";
arraydanwei[23]= "人次";
arraydanwei[24]= "人";
arraydanwei[25]= "%";
arraydanwei[26]= "人";
arraydanwei[27]= "%";
arraydanwei[28]= "人";
arraydanwei[29]= "%";
arraydanwei[30]= "人";
arraydanwei[31]= "人";
arraydanwei[32]= "min";
arraydanwei[33]= "次";
arraydanwei[34]= "%";
arraydanwei[35]= "人";
arraydanwei[36]= "人";
arraydanwei[37]= "人";
arraydanwei[38]= "%";
arraydanwei[39]= "%";
arraydanwei[40]= "人";
arraydanwei[41]= "人次";
arraydanwei[42]= "/";
arraydanwei[43]= "人";
arraydanwei[44]= "人次/人";
arraydanwei[45]= "笔";
arraydanwei[46]= "天";

 //指标
var array=new Array();
 //指标
var arrayGroup=new Array();


/**
 * 设置图表属性
 */
//折线是否为平滑 true：平滑折线，false平常折线
var smoothType = true; 
//图表横坐标轴上的分割灰线
var xAxisSplitLine = true;
//图表纵坐标轴上的分割灰线
var yAxisSplitLine = true;
//区域竖向
var xAxissplitArea = false;
//横向区域
var yAxissplitArea = true;
//grid区域边框
var gridBorderWidth = 1




//横坐标大于30个不显示数值
 function getShow(xsis){
	 //var i=xsis.length;
	 //if(i<=30){ return true;}
	 //else{return false;}
	 return false;
 }
//click时间
function shijianCss(span){
	var spanArr=span.split("_");
	$("#divDay > table >tbody> tr > td").removeClass("lxxzselected");
	$("#shijianduibi").removeClass("lxxzselected");
	$("#txtspan").val(span);
	if (spanArr[1] != "0") {
		$("#"+span+"").addClass("lxxzselected");
	}else{
		$("#shijianduibi").addClass("lxxzselected");
	}
}
//click指标
function zhibiaoCss(type){
	$("#zhibiao_"+type).css("backgroundColor","#f6f6f6");
}
 
//导出Excle  getExportExcle，对于行数不太变化的小型table导出（url参数不能超过2000字节）
function outExcel(divName,divDescribe,fileName){
	var character = "utf-8";
	var mb = myBrowser();
	if ("IE" == mb) {
	}
	if ("FF" == mb) {
	   character =  "GB2312"
	}
	if ("Chrome" == mb) {
	}
	if ("Opera" == mb) {
	}
	if ("Safari" == mb) {
	}
	var testdate = new Date("yyyy,mth,dd,hh,mm,ss");
	console.log(testdate);
	var date = new Date;
	var today = timeFormat(date)
	var table=$("#"+divName).val();
	var titleName = $("#titles").val();
	var fileName = titleName+"-"+fileName+today;
	fileName = fileName.replace(/\s+/g,"");
	fileName = fileName.replace("&","");
	var describe = $("#"+divDescribe).html();
	describe = describe.replace('&amp;','&');
	describe = encodeURI(describe); 
	table = encodeURI(table); 
	fileName = encodeURI(fileName); 
	$("#ExportExcle").children("input[name='table']").val(table)
	$("#ExportExcle").children("input[name='fileName']").val(fileName)
	$("#ExportExcle").children("input[name='character']").val(character)
	$("#ExportExcle").children("input[name='describe']").val(describe)
	$("#ExportExcle").submit();
}
/*
格式化称yyyymtddhhmmss
*/
function timeFormat(date){
	var year = date.getFullYear();
	var month = (date.getMonth()+1);
	var day = date.getDate();
	var hour = date.getHours();
	var minutes = date.getMinutes();
	var seconds = date.getSeconds();
	if (month<10) {
		month = '0'+month
	} else {
		month = ''+month
	}
	if (day<10) {
		day = '0'+day
	} else {
		day = ''+day
	}
	if (hour<10) {
		hour = '0'+hour
	} else {
		hour = ''+hour
	}
	if (minutes<10) {
		minutes = '0'+minutes
	} else {
		minutes = ''+minutes
	}
	if (seconds<10) {
		seconds = '0'+seconds
	} else {
		seconds = ''+seconds
	}
	return year+month+day+hour+minutes+seconds
} 
 
function myBrowser(){
    var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
    var isOpera = userAgent.indexOf("Opera") > -1;
    if (isOpera) {
        return "Opera"
    }; //判断是否Opera浏览器
    if (userAgent.indexOf("Firefox") > -1) {
        return "FF";
    } //判断是否Firefox浏览器
    if (userAgent.indexOf("Chrome") > -1){
  return "Chrome";
 }
    if (userAgent.indexOf("Safari") > -1) {
        return "Safari";
    } //判断是否Safari浏览器
    if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
        return "IE";
    }; //判断是否IE浏览器
} 
 //指标tip
 $(document).ready(function () {
    // 使用each（）方法来获得每个元素的属性
    $('img[src="images/ts.png"]').each(function () {
        $(this).qtip({
            content: {
                // 设置您要使用的文字图像的HTML字符串，正确的src URL加载图像
        		//text: '<img class="throbber" src="loading.gif" alt="Loading..." />',
                url: "jsp/help.html", // 使用的URL加载的每个元素的rel属性
                title: {
                    text: $(this).attr("title"), // 给工具提示使用每个元素的文本标题
                    //button: '关闭' // 在标题中显示关闭文字按钮
                }
            },
            position: {
				//corner: {
					//target: 'bottomMiddle',
					//tooltip: 'topMiddle'
				//},
                corner: {  
                    tooltip: 'bottomLeft',  
                    target: 'topRight'  
                  },
                adjust: {
                    screen: true // 在任何时候都保持提示屏幕上的
                }
            },
            show: {
                when: 'mouseenter', // 或click
                solo: true // 一次只显示一个工具提示
            },
            hide: 'mouseout',
            style: {
                tip: true, // 设置一个语音气泡提示在指定工具提示角落的工具提示
                border: {
                    width: 0,
                    radius: 4
                },
                name: 'light', // 使用默认的淡样式
                width: 390 // 设置提示的宽度
            }
        })
    });
});
//点击指标出发的事件
 function getinfo(lx,Object) {
 	initPaihIndexArr();
	 if(Object!=""){
		 $(Object).parent("tr").siblings("tr").each(function(){
			 $(this).children("td").css("backgroundColor","white");
		 })
		 	 $(Object).css("backgroundColor","#f6f6f6");
		}
     $("#hdtype").val(lx);
     loadChart(lx);
 } 
 	
//点击日期重新加载折线排行图表
 function getspan(span) {
 	initPaihIndexArr();
 	span.replace(/(^\s*)|(\s*$)/g,'');
 	var spanArr=span.split("_");
 	shijianCss(span);
 	if (spanArr[1] != "0") {
 	    loadChart($("#hdtype").val());
// 	    loadPaiHang($("#siteKey").val(), $("#hdtype").val());
 	}
// 	$("#txtspan").val(span);
 }
 
//加载图表
 function loadTable(result) {
             $("#hdtable").val(result);
			 /**
			  * 测试
			  */
			 $("#datatable").html(result);
			 $('#tabledata').dataTable({
//				"scrollX": true,
//				//添加横向滚动条
//				"searching": false,
//				//取消搜索
//				//"bProcessing": true,
//				//显示正在加载
//				"bPaginate": true,
//				"bLengthChange": false,
//				"aaSorting": [
//					[0, "desc"]
//				],
				//默认第几个排序
				 "scrollX": '400px',//添加横向滚动条
					"searching":false,//取消搜索
					 "bProcessing": true,//显示正在加载
					 "bPaginate": true   ,
					 "bLengthChange": false,
					"aaSorting": [[ 0, "asc" ]],//默认第几个排序
					"bStateSave": false,//状态保存
					"bRetrieve": true,
					"bAutoWidth": true,
//					"aoColumnDefs": [
//					  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
//					  {"orderable":false,"aTargets":[0,5]}// 制定列不参与排序
//					],
				language: {
					"sProcessing": "处理中...",
					"sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
					"sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
					"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
					"sInfoPostFix": "",
					"sUrl": "",
					"sEmptyTable": "表中数据为空",
					"sLoadingRecords": "载入中...",
					"sInfoThousands": ",",
					"oPaginate": {
						"sFirst": "首页",
						"sPrevious": "上页",
						"sNext": "下页",
						"sLast": "末页"
					},
					"oAria": {
						"sSortAscending": ": 以升序排列此列",
						"sSortDescending": ": 以降序排列此列"
					}
				}
			}
			);
	//showtable(1);
 }
 //显示图表
 function showtable(pageindex){
     var ret=$("#hdtable").val();
     var size=parseInt($("#hdtablesize").val());
     var index=ret.indexOf("</th></tr>");
     var head=ret.substr(0,index+10);
     var index2=ret.indexOf("</table>");
     var foot=ret.substr(index2,ret.length-1);
     ret=ret.substring(index+10,index2);
     var rets=ret.split("</tr>");
     
//     if((rets.length-1)<=size)
//     {
//         $("#divfanye").css("display","none");
//     }else{
//         $("#divfanye").css("display","");
//     }
     
     if(pageindex==1){
         if((rets.length-1)%size==0){
             $("#allpage").text(parseInt((rets.length-1)/size));
         }else{
             $("#allpage").text(parseInt((rets.length-1)/size+1));
         }
     }
     $("#divfanye img[src='images/fanye2_left.png']").parent("div").show();
	 $("#divfanye img[src='images/fanye2_right.png']").parent("div").show();
     if (parseInt($("#allpage").text()) == 1) {
    	 	$("#divfanye img[src='images/fanye2_left.png']").parent("div").hide();
    	 	$("#divfanye img[src='images/fanye2_right.png']").parent("div").hide();
		}
	if (pageindex == 1) {
		$("#divfanye img[src='images/fanye2_left.png']").parent("div").hide();
	}
	if (pageindex == parseInt($("#allpage").text())) {
		$("#divfanye img[src='images/fanye2_right.png']").parent("div").hide();
	}
 
     
     var sindex=(pageindex-1)*size;
     var eindex=pageindex*size-1;
     if(eindex>rets.length-1){
         eindex=rets.length-1;
     }
     var ret="";
     for(i=sindex;i<=eindex;i++)
     {
         ret+=rets[i]+"</tr>";
     }
     $("#datatable").html(head+ret+foot);
     $("#curpage").text(pageindex);
 }

 //翻页
 function gotopage(i){
//	    var curpage=parseInt($("#curpage").text());
//	    var allpage=parseInt($("#allpage").text());
//	    if(type==-1)
//	    {
//	        if(curpage!=1){
//	            curpage--;
//	        }
//	    }
//	    else if(type==1){
//	        if(curpage!=allpage){
//	            curpage++;
//	        }
//	    }
//	    else if(type==2)
//	    {
//	        if(parseInt($("#txtpages").val())<=allpage&&parseInt($("#txtpages").val())>=1){
//	            curpage=parseInt($("#txtpages").val());
//	        }
//	        else
//	        {
//	            alert("提示","超出范围！");
//	        }
//	    }
//	    else if(type==3){
//	        curpage=allpage;
//	    }
		
		// 纯数字正则
		var numRule = /(^\d*$)|(^\S+\s+\S+$)/;
		var j = 1;
		var maxPage = parseInt($("#allpage").html());
		// 首页
		if (i == 0) {
			j = 1;
		}
		// 下一页
		else if (i == 1) {
			j = parseInt($("#curpage").html()) + 1;
		}
		// 上一页
		else if (i == -1) {
			j = parseInt($("#curpage").html()) - 1;
		}
		// 跳转
		else if (i == 2) {
			var gotoPage = $("#txtpages").val().trim();
			if (gotoPage == "") {
				j = 1;
			} else if (!gotoPage.match(numRule)) {
				j == 1
			} else {
				j = parseInt(gotoPage);
			}
		}
		// 尾页
//		else if (i == -1) {
//			j = maxPage;
//		}
		if (j < 1) {
			j = 1;
		}
		if (j > maxPage) {
			j = maxPage;
		}
//		$("#gotoPage").val(j);
		
	    showtable(j);
	}

function dispDayDivChildren(){
	 	$("#divDay").children().toggle();
}
function hourDivDisplay(){
	if ($("#needCompare").val() == "0") {
		$("#hour_1").css("display","");
		$("#hour_2").css("display","");
	}
}
function dayDivDisplay(){
	if ($("#needCompare").val() == "0") {
		$("#day_1").css("display","");
		$("#day_7").css("display","");
		$("#day_14").css("display","");
		$("#day_30").css("display","");
	}
	 
}
function weekDivDisplay(){
	 if ($("#needCompare").val() == "0") {
		$("#week_4").css("display","");
		$("#week_8").css("display","");
		$("#week_12").css("display","");
	 }
}
function monthDivDisplay(){
	 if ($("#needCompare").val() == "0") {
		$("#month_3").css("display","");
		$("#month_6").css("display","");
		$("#month_12").css("display","");
	 }
}
function yearDivDisplay(){
	if ($("#needCompare").val() == "0") {
		$("#year_3").css("display","");
		$("#year_5").css("display","");
		}
}
//历史详解
function writeIndex(timeModel){
	var index = $("#indexList").val();
	index = eval(index);
	var indextTime = "";
	if (timeModel == "hour") {
		indextTime = $("#indexHour").val();
	}
	else if (timeModel == "day") {
		indextTime = $("#indexDay").val();
	}
	else if (timeModel == "week") {
		indextTime = $("#indexWeek").val();
	}
	else if (timeModel == "month") {
		indextTime = $("#indexMonth").val();
	}
	else {
		indextTime = $("#indexYear").val();
	}
	indextTime = eval(indextTime);
	var name = new Array();
	for (var i=0; i<indextTime.length; i++) {
		if(contains(index,indextTime[i])){
			name.push(indextTime[i])
		}
	};
	var zhibiaotable = "";
	for (var i=0; i<name.length; i++) {
		var zhibiao = name[i];
		zhibiaotable = zhibiaotable +"<tr><td id='zhibiao_"+zhibiao+"' class='em35 lineh35' onclick='getinfo("+zhibiao+",this)'>"+array[zhibiao]+"</td></tr>"
	};
	$("#zhibiaotable").html(zhibiaotable);
	//取页面中有权限的第一个指标
	$("#hdtype").val(name[0])
}








function changeTime(time){
		initPaihIndexArr();
	if (time == "Hour") {
		$("#timeModel").val("hour");
		if ($("#needCompare").val() == "1") {
			timecomparefn();
		}
		hourDateObj();
		 $("#Hour").addClass("lxxzselected");
		 $("#Day").removeClass("lxxzselected");
		 $("#Week").removeClass("lxxzselected");
		 $("#Month").removeClass("lxxzselected");
		 $("#Year").removeClass("lxxzselected");
		 $("#divDay > table >tbody> tr > td").css("display","none");
		 hourDivDisplay();
		 if ($("#needCompare").val() == "0") {
			 $("#txtspan").val("hour_1");
		 }else{
			 $("#txtspan").val("hour_0");
		 }
	}else if(time=="Day"){
		 $("#timeModel").val("day");
		if ($("#needCompare").val() == "1") {
			timecomparefn();
		}
		rizhouDateObj();
		 $("#Hour").removeClass("lxxzselected");
		 $("#Day").addClass("lxxzselected");
		 $("#Week").removeClass("lxxzselected");
		 $("#Month").removeClass("lxxzselected");
		 $("#Year").removeClass("lxxzselected");
		 $("#divDay > table >tbody> tr > td").css("display","none");
		 dayDivDisplay();
		
		 if ($("#needCompare").val() == "0") {
			 $("#txtspan").val("day_7");
		 }else{
			 $("#txtspan").val("day_0");
		 }
	 }else if(time=="Week"){
	 	$("#timeModel").val("week");
	 	if ($("#needCompare").val() == "1") {
		timecomparefn();
		}
	 	rizhouDateObj();
		 $("#Hour").removeClass("lxxzselected");
		 $("#Day").removeClass("lxxzselected");
		 $("#Week").addClass("lxxzselected");
		 $("#Month").removeClass("lxxzselected");
		 $("#Year").removeClass("lxxzselected");
		 $("#divDay > table >tbody> tr > td").css("display","none");		 
		 weekDivDisplay();
		 if ($("#needCompare").val() == "0") {
			 $("#txtspan").val("week_4");
		 }else{
			 $("#txtspan").val("week_0");
		 }
	 }else if(time=="Month"){
	 	 $("#timeModel").val("month");
	 	if ($("#needCompare").val() == "1") {
			timecomparefn();
		}
	 	rizhouDateObj();
		 $("#Hour").removeClass("lxxzselected");
		 $("#Day").removeClass("lxxzselected");
		 $("#Week").removeClass("lxxzselected");
		 $("#Month").addClass("lxxzselected");
		 $("#Year").removeClass("lxxzselected");
		 $("#divDay > table >tbody> tr > td").css("display","none");		 
		 monthDivDisplay();
		
		 if ($("#needCompare").val() == "0") {
			 $("#txtspan").val("month_3");
		 }else{
			 $("#txtspan").val("month_0");
		 }
	 }else{
	 	$("#timeModel").val("year");
	 	if ($("#needCompare").val() == "1") {
		timecomparefn();
		}
	 	rizhouDateObj();
		 $("#Hour").removeClass("lxxzselected");
		 $("#Day").removeClass("lxxzselected");
		 $("#Week").removeClass("lxxzselected");
		 $("#Month").removeClass("lxxzselected");
		 $("#Year").addClass("lxxzselected");
		 $("#divDay > table >tbody> tr > td").css("display","none");		 
		 yearDivDisplay();
		 
		 if ($("#needCompare").val() == "0") {
			 $("#txtspan").val("year_3");
		 }else{
			 $("#txtspan").val("year_0");
		 }
	 }
	 getIndexOrder();
//	 loadChart($("#hdtype").val());
//  loadTable();
} 

//去掉没有的广场类型的option
function removeSelectOption(changsuoleix){
	$("#select_changsuo").children().each(function(){
		  var leix =$(this).attr("value");
		  if(!contains(changsuoleix,leix)){
				$(this).remove()
			};
	} ) 
 }



//查看对象是否子array中存在
function contains(arr, obj) {
	if( arr ==null){
		 return false;  
	}
    var i = arr.length;  
    while (i--) {  
        if (arr[i] === parseInt(obj)) {  
            return true;  
        }  
    }  
    return false;  
} 



function readychange(){
	$("#guojiaCombo>option").remove();
	$('#guojiaCombo').html("<option value='-1'>请选择</option>");
	var guojiaList = eval($('#guojia').val());
	for ( var i = 0; i < guojiaList.length; i++) {
		$(
				"<option value=" + guojiaList[i].siteid + ">"
						+ guojiaList[i].sitename + "</option>").appendTo(
				$('#guojiaCombo'));
	}
}

//根据年周的周一和周日
function getTiptollTime(Str){
	var date = Str;
	if(date=="平均值"){
		return "平均值";
	}
	date = date.split(".");
	var year = date[0]
	var week = date[1];
	return getXDate(year,week,1)+"~"+getXDate(year,week,7);
} 

//根据年周的周一
function getTiptollmon(Str){
	var date = Str;
	date = date.split("-");
	var year = date[0]
	var week = date[1];
	return getXDate(year,week,1);
} 
//根据年周的周日
function getTiptollsun(Str){
	var date = Str;
	date = date.split("-");
	var year = date[0]
	var week = date[1];
	return getXDate(year,week,7);
} 

//这个方法将取得某年(year)第几周(weeks)的星期几(weekDay)的日期
function getXDate(year,weeks,weekDay){
//用指定的年构造一个日期对象，并将日期设置成这个年的1月1日
//因为计算机中的月份是从0开始的,所以有如下的构造方法
var date = new Date(year,"0","1");

//取得这个日期对象 date 的长整形时间 time
var time = date.getTime();

//将这个长整形时间加上第N周的时间偏移
//因为第一周就是当前周,所以有:weeks-1,以此类推
//7*24*3600000 是一星期的时间毫秒数,(JS中的日期精确到毫秒)
time+=(weeks-1)*7*24*3600000;

//为日期对象 date 重新设置成时间 time
date.setTime(time);
return getNextDate(date,weekDay);
}

//这个方法将取得 某日期(nowDate) 所在周的星期几(weekDay)的日期
function getNextDate(nowDate,weekDay){
//0是星期日,1是星期一,...
//weekDay%=7;
var day = nowDate.getDay();
var time = nowDate.getTime();
var sub = weekDay-day;
time+=sub*24*3600000;
nowDate.setTime(time);

var ryear = nowDate.getFullYear()
var rmonth = (nowDate.getMonth()+1);
if(rmonth<10){
	rmonth = "0"+rmonth
}
var rday = nowDate.getDate();
if(rday<10){
	rday = "0"+rday
}
return ryear+"-"+rmonth+"-"+rday;
}
/**
 * 千分位
 * @param number
 * @return
 */
function addKannma(number) {
    var num = number + "";  
    num = num.replace(new RegExp(",","g"),"");   
    // 正负号处理   
    var symble = "";   
    if(/^([-+]).*$/.test(num)) {   
        symble = num.replace(/^([-+]).*$/,"$1");   
        num = num.replace(/^([-+])(.*)$/,"$2");   
    }   
  
    if(/^[0-9]+(\.[0-9]+)?$/.test(num)) {   
        var num = num.replace(new RegExp("^[0]+","g"),"");   
        if(/^\./.test(num)) {   
        num = "0" + num;   
        }   
  
        var decimal = num.replace(/^[0-9]+(\.[0-9]+)?$/,"$1");   
        var integer= num.replace(/^([0-9]+)(\.[0-9]+)?$/,"$1");   
  
        var re=/(\d+)(\d{3})/;  
  
        while(re.test(integer)){   
            integer = integer.replace(re,"$1,$2");  
        }   
        return symble + integer + decimal;   
  
    } else {   
        return number;   
    }   
}
/**
 * 获取对象属性的值
 * @param Object
 * @param indexName
 * @return
 */
function getObjectVlue(Object,indexName){
	for(var p in Object){
		if(p==indexName){
			return Object[p];
		}
	}
}
/**
 * 获取对象属性的最大值
 * @param Object
 * @param indexName
 * @return
 */
function getFildeMaxValue(parseDate,indexName){
	var max = 0;
	for(var i = 0 ;i<parseDate.length;i++){
		var value = getObjectVlue(parseDate[i],indexName);
		if(value>max){
			max = value;
		}
	}
	return max;
}
/**
 * @author wyp
 * 0= "客流量";1= "集客力";2= "人效";3= "销售额";4= "提袋率";
 * 5= "客单价";6= "坪效";7= "顾客数";8= "平均游逛时间";9= "新顾客数";10= "老顾客数";11= "新顾客占比";
 * 12= "老顾客占比";13= "进店率";14= "返店率";15= "流失量";16= "流失率";17= "回流量";18= "回流率";19= "会员人数";20= "会员人数占比";
 * 21 = '平均滞留时间'
 * @param orderFieldNum
 * @return
 */
function  getOrderField(orderFieldNum){
	var orderField = "";
	switch(parseInt(orderFieldNum)){
		case 0:orderField = "innum";break;
		case 1:orderField = "jkl";break;
		case 2:orderField = "posStaff";break;
		case 3:orderField = "pos";break;
		case 4:orderField = "rateBags";break;
		case 5:orderField = "posInnum";break;
		case 6:orderField = "posArea";break;
		case 7:orderField = "customerNum";break;
		case 8:orderField = "avgWanderTime";break;
		case 9:orderField = "newCustomerNum";break;
		case 10:orderField = "oldCustomer";break;
		case 11:orderField = "newCustomerPro";break;
		case 12:orderField = "oldCustomerPro";break;
		case 13:orderField = "inStoreRates";break;
		case 14:orderField = "returnStoreRates";break;
		case 15:orderField = "lossUserNum";break;
		case 16:orderField = "lossRates";break;
		case 17:orderField = "backUserNum";break;
		case 18:orderField = "backRates";break;
		case 19:orderField = "memNum";break;
		case 20:orderField = "memNumPro";break;
		case 21:orderField = "retentionavg";break;
		case 22:orderField = "retentionNum";break;
		case 23:orderField = "outnum";break;
		case 24:orderField = "activeUserNum";break;
		case 25:orderField = "activeRates";break;
		case 26:orderField = "silenceUserNum";break;
		case 27:orderField = "silenceRates";break;
		case 28:orderField = "stayUserNum";break;
		case 29:orderField = "stayRates";break;
		case 30:orderField = "interNum";break;
		case 31:orderField = "newInterNum";break;
		case 32:orderField = "interAvgDuration";break;
		case 33:orderField = "interAvgCount";break;
		case 34:orderField = "connectRates";break;
		case 35:orderField = "conUserNum";break;
		case 36:orderField = "newAddUserNum";break;
		case 37:orderField = "firstArrNum";break;
		case 38:orderField = "firstArrRates";break;
		case 39:orderField = "wifiOpenRate";break;
		case 40:orderField = "hisUserNum";break;
		case 41:orderField = "inCount";break;
		case 42:orderField = "wanderDepth";break;
		case 43:orderField = "memTotalNum";break;
		case 44:orderField = "serviceAbility";break;
		case 45:orderField = "posnum";break;
		case 46:orderField = "avgActDayNum";break;
		default:orderField = "";break;
	} 
	return orderField;
}
/**
 * 获取字符串的字节数
 * @param {Object} str
 */
function getBytesLength(str){
	// 在GBK编码里，除了ASCII字符，其它都占两个字符宽
	str
	return str.replace(/[^\x00-\xff]/g, 'xx').length;
}

function containsStr(arr, obj) {
    var i = arr.length;  
    while (i--) {  
        if (arr[i] == obj) {  
            return true;  
        }  
    }  
    return false;  
} 

/**
 * 将对象的数值转为doubel类型
 * @param {Object} Object
 * @param {Object} indexNames
 */
function changeStringTodouble(Object,indexNames){
	var arr = new Array();
	arr = indexNames;
	for(var p in Object){
		for(var o in Object[p]){
			if(containsStr(arr,o)){
				var str = (Object[p])[o];
				if(str!=""&&str!=null){
					(Object[p])[o] = parseInt(str);
				}else{
					(Object[p])[o] = 0;
				}
			}
		}
	}
	
	return Object;
}

/**
 *在字符串特定位置插入字符 
 * @param {Object} str表示原字符串变量
 * @param {Object} flg表示要插入的字符串
 * @param {Object} sn表示要插入的位置
 */
function insert_flg(str,flg,sn){
    var newstr="";
    for(var i=0;i<str.length;i+=sn){
        var tmp=str.substring(i, i+sn);
        newstr+=tmp+flg;
    }
    return newstr;
}
 
function getLength(str){

　　var byteLen=0;
	var len=str.length;
　　if(str){
　　　　for(var i=0; i<len; i++){
　　　　　　if(str.charCodeAt(i)>255){
　　　　　　　　byteLen += 2;
　　　　　　}
　　　　　　else{
　　　　　　　　byteLen += 1.3;
　　　　　　}
　　　　}
　　　　return byteLen;
　　}
　　else{
　　　　return 0;
　　}

}

/**
 * 删除数组中某项
 * @param {Object} val
 */
Array.prototype.remove = function(val) {
	var index = this.indexOf(val);
	if (index > -1) {
		this.splice(index, 1);
	}
}

/**
 * 查找数组中元素的位置
 * @param {Object} val
 */
Array.prototype.indexOf = function(val) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == val) return i;
	}
	return -1;
};
